package com.hh.usersystem.action;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;

import com.hh.baseframework.util.MessageException;
import com.hh.baseframework.util.base.BaseServiceAction;
import com.hh.baseframework.util.dto.ExtCheckTree;
import com.hh.baseframework.util.dto.ExtTree;
import com.hh.baseframework.util.model.ReturnModel;
import com.hh.system.service.impl.BaseService;
import com.hh.usersystem.bean.usersystem.HhXtCd;
import com.hh.usersystem.service.impl.MenuService;
import com.opensymphony.xwork2.ModelDriven;

@SuppressWarnings("serial")
public class Actionmenu extends BaseServiceAction<HhXtCd> implements ModelDriven<HhXtCd> {
	private HhXtCd hhXtCd = new HhXtCd();
	private String roleid;
	@Autowired
	private MenuService menuService;
	@Override
	public BaseService<HhXtCd> getService() {
		return menuService;
	}

	public HhXtCd getModel() {
		return hhXtCd;
	}

	public void queryPagingData() {
		this.returnResult(menuService.queryPagingData(hhXtCd,
				this.getPageRange()));
	}

	public void save() {
		try {
			HhXtCd hhXtCd = menuService.save(this.hhXtCd);
			this.getResultMap().put("object", hhXtCd);
		} catch (MessageException e) {
			this.getResultMap().put("returnModel",
					new ReturnModel(e.getMessage()));
		}
		this.returnResult();
	}

	public void findObjectById() {
		HhXtCd hhXtCd = menuService.findObjectById(this.hhXtCd.getId());
		this.returnResult(hhXtCd);
	}

	public void queryMenuListByPid() {
		List<ExtTree> hhxtcdList = menuService.queryMenuListByPid(hhXtCd
				.getNode());
		this.returnResult(hhxtcdList);
	}

	public void queryMenuAllListByPid() {
		List<ExtCheckTree> hhxtcdList = menuService.queryMenuAllListByPid(
				hhXtCd.getNode(), roleid);
		this.returnResult(hhxtcdList);
	}

	public void deleteByIds() {
		menuService.deleteByIds(this.getIds());
	}

	public void addZmtb() {
		menuService.addZmtb(hhXtCd.getId());
	}

	public void deleteZmtb() {
		menuService.deleteZmtb(hhXtCd.getId());
	}

	public String getRoleid() {
		return roleid;
	}

	public void setRoleid(String roleid) {
		this.roleid = roleid;
	}

}
